﻿Imports TBCC.UtilityMobile
Public Class DBBackupPathConfigForm

    Private Const _dbFileKey As String = "DBBackup2Path"

    Private Const _TimeKey As String = "DBBackupTime"


    Private Sub DBBackupPathConfigForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadFileName()
    End Sub

    Private Sub LoadFileName()
        Me.TextBox1.Text = KeyValuePairClass.GetValue(MainForm.pi.ProjectID, _dbFileKey)

        Dim strTime As String
        strTime = KeyValuePairClass.GetValue(MainForm.pi.ProjectID, _TimeKey)
        strTime = strTime.Trim()
        If strTime = "" Then
            strTime = "00:00:00"
        End If

        strTime = "2008-07-15 " & strTime

        Try
            Me.DateTimePicker1.Value = DateTime.Parse(strTime)
        Catch ex As Exception
            Me.DateTimePicker1.Value = Now
        End Try

    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()

        'Dim path As String
        'path = KeyValuePairClass.GetValue(_dbFileKey)
        'If path = "" OrElse Not System.IO.Directory.Exists(path) Then
        '    Exit Sub
        'End If

        'Dim file As String
        'file = path & "\" & String.Format("database{0}.bak", Now.ToString("yyyy-MM-dd"))

        'Dim cFile As String = Application.StartupPath & "\" & "config.dat"

        'System.IO.File.Copy(cFile, file, True)

    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim fileName As String
        fileName = Me.TextBox1.Text.Trim()
        'If fileName.Trim() = "" Then
        '    msg.ShowWarning("请选择数据库备份路径")
        '    Me.btnBrowser.Focus()
        '    Exit Sub
        'End If

        KeyValuePairClass.SetValue(MainForm.pi.ProjectID, _dbFileKey, fileName)

        KeyValuePairClass.SetValue(MainForm.pi.ProjectID, _TimeKey, Me.DateTimePicker1.Value.ToString("HH:mm:ss"))

        msg.Show("保存成功")

        '++++++++++++++++++++++++++++++++++
        'Dim path As String
        'path = KeyValuePairClass.GetValue(_dbFileKey)
        'If path = "" OrElse Not System.IO.Directory.Exists(path) Then
        '    Exit Sub
        'End If

        'Dim file As String
        'file = path & "\" & String.Format("database{0}.bak", Now.ToString("yyyy-MM-dd"))

        'Dim cFile As String = Application.StartupPath & "\" & "config.dat"

        'System.IO.File.Copy(cFile, file, True)

        '+++++++++++++++++++++++++++++++++++++++++++=


    End Sub



    Private Sub btnBrowser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowser.Click
        Dim dlg As New FolderBrowserDialog()
        If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Me.TextBox1.Text = dlg.SelectedPath
        End If
    End Sub
End Class